package com.kompas.bola.application.adapter;

import com.kompas.bola.application.fragment.DetailFragment;
import com.kompas.bola.application.utils.Constants;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

public class SwipeNavigationAdapter extends FragmentStatePagerAdapter {  
	private String _getKanal;
	private String _getGuid;
	private int _getCountRelated;
	private int _getCountList;
	private int _getParam;
	/** ========================================================== */
	public SwipeNavigationAdapter(FragmentManager fm,
			String kanal,String guid,int count_related,int countList,
			int param) {
		super(fm);
		_getKanal							= kanal;
		_getGuid							= guid;
		_getParam							= param;		
		_getCountRelated					= count_related;
		_getCountList						= countList;
	}
	/** ========================================================== */
	public Fragment getItem(int i) {
		Fragment fragment					= new DetailFragment(_getKanal,
											_getGuid,true,_getParam);
		Bundle bundle						= new Bundle();
		
		bundle.putInt(DetailFragment.OFFSET, i + 1);
		
		fragment.setArguments(bundle);	
		return fragment;
	}
	/** ========================================================== */
	@Override
	public int getCount() {
		int count 							= 0;    	
		
		switch (_getParam) {
		case Constants.DETAIL_RELATED:
			count							= _getCountRelated;				
			break;
		case Constants.DETAIL_MAIN:
			count							= _getCountList;				
			break;
		case Constants.DETAIL_BOOKMARK:
			count							= _getCountList;				
			break;

		default:
			break;
		}
		
		return count;
	}
	/** ========================================================== */
}
